package com.zhangqi.qiojbackenduserservice.controller.inner;


import com.zhangqi.qiojbackendmodel.entity.User;
import com.zhangqi.qiojbackendserviceclient.service.UserFeignClient;
import com.zhangqi.qiojbackenduserservice.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collection;
import java.util.List;
@RestController
@RequestMapping("/inner")
public class UserFeignController implements UserFeignClient {

    @Autowired
    private UserService userService;


    /**
     * 根据用户ID获取用户信息
     * @param userId
     * @return
     */

    @Override
    @GetMapping("/get/id")
    public User getById(@RequestParam("userId") long userId){
        return userService.getById(userId);
    }


    /**
     * 根据ID集合过去该集合对应的用户
     * @param userIds
     * @return
     */
    @GetMapping("/get/ids")
    @Override
    public List<User> listByIds(@RequestParam("userIds") Collection<Long> userIds){
        return userService.listByIds(userIds);
    }

}
